package com.kfm.demo;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.Enumeration;

public class PackageClass {

    public static void main(String[] args) {
        String packageName = "com.kfm.controller";

        System.out.println(packageName.replace(".", "/"));

        // 获取到 包所在的路径  com/kfm/controller
        try {
            Enumeration<URL> resources = PackageClass.class.getClassLoader().getResources(packageName.replace(".", "/"));

            while (resources.hasMoreElements()){
                URL url = resources.nextElement();

                File file = new File(url.getFile());

                File[] list = file.listFiles((e) -> e.getName().endsWith(".class"));
                System.out.println(Arrays.toString(list));
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
